<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopCommissionLevelTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('shop_commission_level', ['comment' => '分销商等级', 'engine' => 'InnoDB', 'id' => false, 'primary_key' => 'level', 'collation' => 'utf8mb4_general_ci']);
        $table->addColumn('level', 'integer', ['limit'  =>  11, 'null'=> false, 'default' => 0, 'comment' => '权重等级'])
            ->addColumn('name', 'string', ['limit' => 50, 'comment' => '等级名称'])
            ->addColumn('image', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '等级徽章'])
            ->addColumn('commission_rules', 'text', ['comment' => '佣金比例设置'])
            ->addColumn(Column::tinyInteger('upgrade_type')->setDefault(0)->setComment('升级方式'))
            ->addColumn('upgrade_rules', 'text', ['null' => true, 'comment' => '升级规则'])
            ->create();
    }


    /**
     * Migrate Down.
     */
    public function down()
    {
        $table = $this->table('shop_commission_level');
        $table->drop();
    }
}
